And I do get the right window so the good constructor is called.
I'm new to C++ but not to object programming. I'm pretty sure that with
object pascal I would get the overloaded method!!!
I triied to trace with the debugger and it seems that the descendant class
is damaged by the compiler because though I initialize its extra data in
the constructor, they appear randomly modified. This modification seems to
be quite fast because if I do the following:
TBezierSectionDocument *theTBSDocument;
switch (theDocType)
{ case tSectionBezierDoc :
{ theTBSDocument= new TBezierSectionDocument();
theTBSDocument->DoCmd(0);
I do get the parent method .
I have other class build and inherited a la object pascal and they do work well.
I use ToolsPlus. Already heard of such problems incurring from it?
Any help would be _greatly_ appreciated
TIA
--
Alain Bertrand
nakaaran@micronet.fr
+++++++++++++++++++++++++++
From bwade@qualia.com (Bretton Wade)
Date: Thu, 10 Oct 1996 11:49:26 -0400
Organization: qualia, inc.
In article <nakaaran-0910962038240001@pppa226.francenet.fr>,
nakaaran@micronet.fr (A. Bertrand) wrote:
# But when I try to call the overloaded DoCmd(short theCmd) I always get the
# parent class mÈthod. I really can't find out where I'm wrong.
Sounds like you are calling DoCmd from the base class constructor. If so,
the behavior you are getting is correct C++. While the base class is
constructing, the object type is that of the base class, thus any virtual
functions called will belong to the base class, and not any inherited
classes. After construction is complete, then any call to the virtual
function will yield the inherited class version.
If you really need to call DoCmd during initialization, the usual practice
is to add a member function called 'initialize', which you call after the
object is constructed.
--
Bretton Wade (bwade@qualia.com)
http://www.qualia.com/~bwade/
+++++++++++++++++++++++++++
From nakaaran@micronet.fr (A. Bertrand)
Date: 10 Oct 1996 23:02:19 GMT
Organization: Francenet -- Paris, France
In article (Dans l'article) <bwade-1010961149260001@frost.qualia.com>,
bwade@qualia.com (Bretton Wade) wrote (Ècrivait)†:
> In article <nakaaran-0910962038240001@pppa226.francenet.fr>,
> nakaaran@micronet.fr (A. Bertrand) wrote:
>
> # But when I try to call the overloaded DoCmd(short theCmd) I always get the
> # parent class mÈthod. I really can't find out where I'm wrong.
>
> Sounds like you are calling DoCmd from the base class constructor. If so,
> the behavior you are getting is correct C++. While the base class is
> constructing, the object type is that of the base class, thus any virtual
> functions called will belong to the base class, and not any inherited
> classes.
Hi,
Thanks a lot for your help, but the problem seems to come from elsewhere.
After constructing my object by
theTBSDocument= new TBezierSectionDocument();
I can call
theTBSDocument->Initialize() which is a method that doesn't belong to the
parent class. I get it.
If I call
theTBSDocument-> DoCmd( theCmd) I get the parent class method.
It seems like the jump table for this object is wrongly built. So why this
one and not the other ? I changed the name of the class but no succes.
Regards,
--
Alain Bertrand
nakaaran@micronet.fr
Ce matin est venu mon medecin. Il s'appelle Werner mais c'est un Russe.Qu'y a-t-il d'etonnant a cela? Je connaissais un Ivanov qui etait allemand. (Lermontov)